package com.wtwd.device.config;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @author zdl
 * @Description
 * @create 2021-08-18 16:42
 */
public class LongToString extends JsonSerializer<Long> {
    @Override
    public void serialize(Long aLong, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        String s = aLong.toString();
        if (s.length() > 16) {
            jsonGenerator.writeString(s);
        }else{
            jsonGenerator.writeNumber(aLong);
        }

    }
}
